package com.bbva.kyfb.kyfbjpatlbh.dominiotlbh;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.roo.addon.dbre.RooDbManaged;
import org.springframework.roo.addon.entity.RooEntity;
import org.springframework.roo.addon.javabean.RooJavaBean;
import org.springframework.roo.addon.tostring.RooToString;
import org.springframework.transaction.annotation.Transactional;

/**
 * The Class Ttlsbfua.
 */
@Entity
@Table(name = "TTLSBFUA",schema = "TLSB")
@Configurable
@RooJavaBean
@RooToString
@RooEntity(identifierType = TtlsbfuaPK.class, versionField = "",  persistenceUnit="persistenceUnitTLBH",table = "TTLSBFUA", schema = "TLSB")
@PersistenceContext(unitName="persistenceUnitTLBH")
@RooDbManaged(automaticallyDelete = true)
public class Ttlsbfua {

	/** The entity manager. */
	@PersistenceContext(unitName= "persistenceUnitTLBH")
    transient EntityManager entityManager;

	/** The id. */
	@EmbeddedId
    private TtlsbfuaPK id;

	/**
	 * Gets the id.
	 *
	 * @return the id
	 */
	public TtlsbfuaPK getId() {
        return this.id;
    }

	/**
	 * Sets the id.
	 *
	 * @param id the new id
	 */
	public void setId(TtlsbfuaPK id) {
        this.id = id;
    }

	/**
	 * Persist.
	 */
	@Transactional(value="tlbh")
    public void persist() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.persist(this);
    }

	/**
	 * Removes the.
	 */
	@Transactional(value="tlbh")
    public void remove() {
        if (this.entityManager == null) this.entityManager = entityManager();
        if (this.entityManager.contains(this)) {
            this.entityManager.remove(this);
        } else {
            Ttlsbfua attached = Ttlsbfua.findTtlsbfua(this.id);
            this.entityManager.remove(attached);
        }
    }

	/**
	 * Flush.
	 */
	@Transactional(value="tlbh")
    public void flush() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.flush();
    }

	/**
	 * Clear.
	 */
	@Transactional(value="tlbh")
    public void clear() {
        if (this.entityManager == null) this.entityManager = entityManager();
        this.entityManager.clear();
    }

	/**
	 * Merge.
	 *
	 * @return the ttlsbfua
	 */
	@Transactional(value="tlbh")
    public Ttlsbfua merge() {
        if (this.entityManager == null) this.entityManager = entityManager();
        Ttlsbfua merged = this.entityManager.merge(this);
        this.entityManager.flush();
        return merged;
    }

	/**
	 * Entity manager.
	 *
	 * @return the entity manager
	 */
	public static final EntityManager entityManager() {
        EntityManager em = new Ttlsbfua().entityManager;
        if (em == null) throw new IllegalStateException("Entity manager has not been injected (is the Spring Aspects JAR configured as an AJC/AJDT aspects library?)");
        return em;
    }

	
	/**
	 * Count ttlsbfuas.
	 *
	 * @return the long
	 */
	@Transactional(value="tlbh")
	public static long countTtlsbfuas() {
        return entityManager().createQuery("SELECT COUNT(o) FROM Ttlsbfua o", Long.class).getSingleResult();
    }

	
	/**
	 * Find all ttlsbfuas.
	 *
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbfua> findAllTtlsbfuas() {
        return entityManager().createQuery("SELECT o FROM Ttlsbfua o", Ttlsbfua.class).getResultList();
    }

	
	/**
	 * Find ttlsbfua.
	 *
	 * @param id the id
	 * @return the ttlsbfua
	 */
	@Transactional(value="tlbh")
	public static Ttlsbfua findTtlsbfua(TtlsbfuaPK id) {
        if (id == null) return null;
        return entityManager().find(Ttlsbfua.class, id);
    }

	
	/**
	 * Find ttlsbfua entries.
	 *
	 * @param firstResult the first result
	 * @param maxResults the max results
	 * @return the list
	 */
	@Transactional(value="tlbh")
	public static List<Ttlsbfua> findTtlsbfuaEntries(int firstResult, int maxResults) {
        return entityManager().createQuery("SELECT o FROM Ttlsbfua o", Ttlsbfua.class).setFirstResult(firstResult).setMaxResults(maxResults).getResultList();
    }

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("AudFmodific: ").append(getAudFmodific()).append(", ");
        sb.append("AudUsuario: ").append(getAudUsuario()).append(", ");
        sb.append("CodEstadfic: ").append(getCodEstadfic()).append(", ");
        sb.append("CodUsuario: ").append(getCodUsuario()).append(", ");
        sb.append("CodUsufirma: ").append(getCodUsufirma()).append(", ");
        sb.append("CodUsupoder: ").append(getCodUsupoder()).append(", ");
        sb.append("FecAccio: ").append(getFecAccio()).append(", ");
        sb.append("FecAccion2: ").append(getFecAccion2()).append(", ");
        sb.append("Id: ").append(getId());
        return sb.toString();
    }

	/** The cod usuario. */
	@Column(name = "COD_USUARIO", columnDefinition = "CHAR",length = 8)
    private String codUsuario;

	/** The fec accio. */
	@Column(name = "FEC_ACCIO", columnDefinition = "CHAR",length = 8)
    private String fecAccio;

	/** The cod usufirma. */
	@Column(name = "COD_USUFIRMA",columnDefinition = "CHAR", length = 8)
    private String codUsufirma;

	/** The cod usupoder. */
	@Column(name = "COD_USUPODER", columnDefinition = "CHAR",length = 8)
    private String codUsupoder;

	/** The cod estadfic. */
	@Column(name = "COD_ESTADFIC", columnDefinition = "CHAR",length = 3)
    private String codEstadfic;

	/** The aud fmodific. */
	@Column(name = "AUD_FMODIFIC", columnDefinition = "DATE")
    @NotNull
    @Temporal(TemporalType.DATE)
    @DateTimeFormat(style = "M-")
    private Date audFmodific;

	/** The aud usuario. */
	@Column(name = "AUD_USUARIO",columnDefinition = "CHAR", length = 8)
    @NotNull
    private String audUsuario;

	/** The fec accion2. */
	@Column(name = "FEC_ACCION2",columnDefinition = "CHAR", length = 8)
    private String fecAccion2;

	/**
	 * Gets the cod usuario.
	 *
	 * @return the cod usuario
	 */
	public String getCodUsuario() {
        return this.codUsuario;
    }

	/**
	 * Sets the cod usuario.
	 *
	 * @param codUsuario the new cod usuario
	 */
	public void setCodUsuario(String codUsuario) {
        this.codUsuario = codUsuario;
    }

	/**
	 * Gets the fec accio.
	 *
	 * @return the fec accio
	 */
	public String getFecAccio() {
        return this.fecAccio;
    }

	/**
	 * Sets the fec accio.
	 *
	 * @param fecAccio the new fec accio
	 */
	public void setFecAccio(String fecAccio) {
        this.fecAccio = fecAccio;
    }

	/**
	 * Gets the cod usufirma.
	 *
	 * @return the cod usufirma
	 */
	public String getCodUsufirma() {
        return this.codUsufirma;
    }

	/**
	 * Sets the cod usufirma.
	 *
	 * @param codUsufirma the new cod usufirma
	 */
	public void setCodUsufirma(String codUsufirma) {
        this.codUsufirma = codUsufirma;
    }

	/**
	 * Gets the cod usupoder.
	 *
	 * @return the cod usupoder
	 */
	public String getCodUsupoder() {
        return this.codUsupoder;
    }

	/**
	 * Sets the cod usupoder.
	 *
	 * @param codUsupoder the new cod usupoder
	 */
	public void setCodUsupoder(String codUsupoder) {
        this.codUsupoder = codUsupoder;
    }

	/**
	 * Gets the cod estadfic.
	 *
	 * @return the cod estadfic
	 */
	public String getCodEstadfic() {
        return this.codEstadfic;
    }

	/**
	 * Sets the cod estadfic.
	 *
	 * @param codEstadfic the new cod estadfic
	 */
	public void setCodEstadfic(String codEstadfic) {
        this.codEstadfic = codEstadfic;
    }

	/**
	 * Gets the aud fmodific.
	 *
	 * @return the aud fmodific
	 */
	public Date getAudFmodific() {
        return this.audFmodific;
    }

	/**
	 * Sets the aud fmodific.
	 *
	 * @param audFmodific the new aud fmodific
	 */
	public void setAudFmodific(Date audFmodific) {
        this.audFmodific = audFmodific;
    }

	/**
	 * Gets the aud usuario.
	 *
	 * @return the aud usuario
	 */
	public String getAudUsuario() {
        return this.audUsuario;
    }

	/**
	 * Sets the aud usuario.
	 *
	 * @param audUsuario the new aud usuario
	 */
	public void setAudUsuario(String audUsuario) {
        this.audUsuario = audUsuario;
    }

	/**
	 * Gets the fec accion2.
	 *
	 * @return the fec accion2
	 */
	public String getFecAccion2() {
        return this.fecAccion2;
    }

	/**
	 * Sets the fec accion2.
	 *
	 * @param fecAccion2 the new fec accion2
	 */
	public void setFecAccion2(String fecAccion2) {
        this.fecAccion2 = fecAccion2;
    }
}
